<template>
  <div class="HuikuiInfo el-card is-always-shadow el-card__body">
    <el-dialog
      title="回馈预览"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-form :disabled="isReload" :option="option" v-model="formData" @submit="handleSubmit">
        <template slot-scope="scope" slot="submitLineCode">
          <el-select v-model="formData.submitLineCode" placeholder="请选择" style="width: 150px" clearable disabled>
            <el-option
              v-for="(item,index) in lineCodes"
              :key="index"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="submitStationCode">
          <el-select v-model="formData.submitStationCode" placeholder="请选择" style="width: 150px" clearable disabled>
            <el-option
              v-for="(item,index) in stationCodes"
              :key="index"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="inLineCode">
          <el-select v-model="formData.inLineCode" placeholder="请选择" style="width: 150px" clearable @change="changeLine" :disabled="showType==2">
            <el-option
              v-for="(item,index) in lineCodesIn"
              :key="index"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="inStationCode">
          <el-select v-model="inStationCode" placeholder="请选择" style="width: 150px" :disabled="showType==2">
            <el-option
              v-for="(item,index) in stationCodesIn"
              :key="index"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="outLineCode">
          <el-select v-model="formData.outLineCode" placeholder="请选择" style="width: 150px" clearable @change="changeLineOut" :disabled="showType==2">
            <el-option
              v-for="(item,index) in lineCodesOut"
              :key="index"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="outStationCode">
          <el-select v-model="outStationCode" placeholder="请选择" style="width: 150px" :disabled="showType==2">
            <el-option
              v-for="(item,index) in stationCodesOut"
              :key="index"
              :label="item.name"
              :value="item.code">
            </el-option>
          </el-select>
        </template>
        <template slot-scope="scope" slot="menuForm" >
          <el-button v-if="showType==1" type="primary" @click="handleSubmit" >确认</el-button>
          <el-button @click="closed" >返回</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";
  import {
    fenExYuangettoFixed,
    getSysDictItemListToDict,
    getgetStationCodes,
    getLineCodes,
    getLineAllAsyn, getStationByCode
  } from "../../api/subwayRat/commonCheck";
  import {updateSwStTicketInformationCheckToQF} from '../../api/clarifyManagement/HKCZTJPKXX';
  import ElInput from "../../../node_modules/element-ui/packages/input/src/input";
  export default {
    components:{
      ElInput
    },
    data() {
      return {
        inStationCode:'',
        outStationCode:'',
        lineCodes:[],
        stationCodes:[],
        lineCodesOut:[],
        stationCodesOut:[],
        lineCodesIn:[],
        stationCodesIn:[],
        option:{},
        showType : 0,
        isReload:true,
        dialogVisible:true,
        formData:{
          submitLineCode:"",
          lineCodesOut:"",
          lineCodesIn:""
        },
      }
    },
    created() {
      // getLineCodes().then(res=>{ //获取线路
      getLineAllAsyn().then(res=>{ //获取线路
        this.lineCodes=res.data;
        this.lineCodesOut=res.data;
        this.lineCodesIn=res.data;
        getStationByCode({line_code:this.formData.submitLineCode}).then(res=>{
          this.stationCodes=res.data;
        })
        getStationByCode({line_code:this.formData.inLineCode}).then(res=>{
          this.stationCodesIn=res.data;
        })
        getStationByCode({line_code:this.formData.outLineCode}).then(res=>{
          this.stationCodesOut=res.data;
        })
      });

      // getgetStationCodes().then(res=>{
      //   this.stationCodes=res;
      // })
    },
    methods: {
      changeLineOut(v){ //改变线路时
        getStationByCode({line_code:v}).then(res=>{
          this.stationCodesOut=res.data;
        })
      },
      changeLine(v){ //改变线路时
        getStationByCode({line_code:v}).then(res=>{
          this.stationCodesIn=res.data;
        })
      },
      async handleSubmit(){
        debugger
        this.formData.inStationCode = this.inStationCode;
        this.formData.outStationCode = this.outStationCode;
        await updateSwStTicketInformationCheckToQF(this.formData).then((response)=>{
        });
        this.$parent.getList();
        this.closed();
      },
      recallShow(row){
        Object.assign(this.formData,row);
        this.getOption();
        this.stationCodesOut = this.stationCodes;
        this.stationCodesIn = this.stationCodes;
        this.inStationCode = row.inStationCode;
        this.outStationCode = row.outStationCode;
        if(2==this.showType){
          this.option.group[0].column[6].disabled = true;
          this.option.group[0].column[9].disabled = true;
          this.option.group[0].column[13].disabled = true;
        }
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.isShowDia=false;
      },
      getOption(){
        this.showType = this.$parent.showType;
        if(1 == this.$parent.showType) {
          this.isReload = false;
        }
        this.option={
          submitBtn:false,
          emptyBtn:false,
          group:[{
              icon:'',
              label: '',
              prop: 'group',
              column: [{
                label: '卡号',
                prop: 'cardOrder',
                disabled:true
              },{
                label: '提交线路',
                prop: 'submitLineCode',
                formslot:true
              },{
                label: '提交站点',
                prop: 'submitStationCode',
                formslot:true
              },{
                label: '录入人',
                prop: 'inputPerson',
                disabled:true,
              },{
                label: '录入人工号',
                disabled:true,
                prop: 'inputPersonCode',
              },{
                label: '录入时间',
                prop: 'inputTime',
                format: 'yyyy-MM-dd',
                valueFormat: 'yyyy-MM-dd',
                disabled:true,
                type:'date'
              },{
                label: '进站时间',
                prop: 'inTime',
                format: 'yyyy-MM-dd',
                valueFormat: 'yyyy-MM-dd',
                type:'date',
              },{
                label: '进站线路',
                prop: 'inLineCode',
                formslot:true
              },{
                label: '进站名称',
                prop: 'inStationCode',
                formslot:true
              },{
                label: '出站时间',
                prop: 'outTime',
                format: 'yyyy-MM-dd',
                valueFormat: 'yyyy-MM-dd',
                type:'date',
              },{
                label: '出站线路',
                prop: 'outLineCode',
                formslot:true
              },{
                label: '出站名称',
                prop: 'outStationCode',
                formslot:true
              },{
                label: '车站金额/次数',
                prop: 'amount',
                disabled:true
              },{
                label: '回馈金额/次数',
                prop: 'replyAmount',
              }]
            }]
        }
      }
    },
    mounted() {
    }
  }
</script>
